import 'package:chat/common/routers/index.dart';
import 'package:chat/global.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';

Future<void> main() async {
  await Global.init();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: "Chat-App",
      debugShowCheckedModeBanner: false,
      // 一开始打开的页面
      initialRoute: RouteNames.splash,
      // 路由
      getPages: RoutePages.pageList,
      navigatorObservers: [RoutePages.observer],

      builder: (context, widget) {
        // EasyLoading 初始化
        widget = EasyLoading.init()(context, widget);
        // 不随系统字体缩放比例
        return MediaQuery(
          data: MediaQuery.of(
            context,
          ).copyWith(textScaler: const TextScaler.linear(1.0)),
          child: widget,
        );
      },
    );
  }
}
